home *** CD-ROM | disk | FTP | other *** search
- { Qdemo.pas - Demonstration program for Q screen utilities ver 2.1, 12-07-86 }
- { Demo has been programmed for All Cards and any column mode. If you want to }
- { try 40 column mode, remove the braces around line 53 and compile. }
- {$I qwik21.inc}
-
- type BrdrRec = record { For Qbox procedure }
- TL,TH,TR,LV,RV,BL,BH,BR: string[1];
- end;
-
- var Row,Rows,Col,Cols,Ctr,Step,Rstep,ColMax,
- Count,Attrib,i,wait,CRTCols: integer;
- HideCursor,OldCursor,Fgrnd,Bgrnd: integer;
- BrdrAttr, WndwAttr: integer;
- SavedBlock, PopUpBlock: array [1..4000] of byte;
- BlkRow,BlkCol: byte;
- Tattr: byte absolute Dseg:$0008; { Location of Turbo's attribute }
- CRTColumns: byte absolute $0040:$004A; { Location of CRT columns }
- ColL,ColR: array [1..3] of byte;
- Strng,NumStr: String[75];
- Data: array [1..9] of String[80];
- Rnum: Real;
-
- const { These are double lines for Qbox }
- Border: BrdrRec = (TL:'╔';TH:'═';TR:'╗';
- LV:'║'; RV:'║';
- BL:'╚';BH:'═';BR:'╝');
-
- { Qbox is an application of Q screen utilities. It can make fast pop up menus.
- Together with Qstore, you can do several windows at one time. }
- procedure Qbox (Row,Col,Rows,Cols: byte; WndwAttr,BrdrAttr: integer;
- Brdr: BrdrRec);
- begin
- if (Rows>=2) and (Cols>=2) then
- begin
- with Brdr do
- begin
- QwriteV (Row ,Col ,BrdrAttr,TL);
- Qfill (Row ,Col+1 ,1 ,Cols-2,BrdrAttr,TH);
- QwriteV (Row ,Col+Cols-1 ,BrdrAttr,TR);
- Qfill (Row+1 ,Col ,Rows-2,1 ,BrdrAttr,LV);
- Qfill (Row+1 ,Col+Cols-1,Rows-2,1 ,BrdrAttr,RV);
- QwriteV (Row+Rows-1,Col ,BrdrAttr,BL);
- Qfill (Row+Rows-1,Col+1 ,1 ,Cols-2,BrdrAttr,BH);
- QwriteV (Row+Rows-1,Col+Cols-1 ,BrdrAttr,BR);
- Qfill (Row+1 ,Col+1 ,Rows-2,Cols-2,WndwAttr,' ')
- end
- end
- end;
-
- begin
- { --- Set up data --- }
- Qinit; { << << Required intializing statement !! }
- { TextMode (C40); } { Remove brackets for test of 40 column mode }
- CRTCols:=CRTColumns;
- Wait:= 500;
- HideCursor:=8192;
- Strng:= ' Q Screen Utilities ';
- Data[1]:= '1';
- Data[2]:= '22';
- Data[3]:= '333';
- Data[4]:= Strng;
- Data[5]:= 'Odd Length';
- Data[6]:= 'Even Length';
- Data[7]:= '18 characters wide';
- Data[8]:= '19 characters width';
- Data[9]:= 'Margin to Margin width';
-
- { --- Initial screen --- }
- CursorChange (HideCursor, OldCursor);
- Qfill ( 1, 1,25,CRTCols,blue shl 4 + white,' '); { Clear Screen }
- QwriteCV (11, 1,CRTCols,blue shl 4 + yellow, Strng);
- QwriteC (13, 1,CRTCols, -1,'Your screen is about to explode.');
- QwriteC (14, 1,CRTCols, -1,'Hold on to your seat ...');
- Delay (Wait*5);
-
- { --- Explosion of Boxes --- }
- Qfill (11, 1, 4,CRTCols, -1,' '); { Clear Lines }
- Qattr ( 1, 1,25,CRTCols,LightGray shl 4); { Change screen attribute }
- Ctr:=CRTCols div 2;
- for step:=2 to Ctr-2 do
- begin
- if Step>24 then Rstep:=12 else Rstep:=Step shr 1;
- for Count:=1 to 20 do
- begin
- Row:= 13 - Rstep + random(Rstep+2);
- Rows:= Rstep;
- Cols:= Rstep + Rstep + Rstep shr 2;
- if step<=24 then Col:=Ctr-Cols+random(Cols+1)
- else Col:= Ctr - 1 - step + random(step+step-22);
- Fgrnd:= random (16);
- Bgrnd:= random (8);
- if Bgrnd=Fgrnd then Fgrnd:=Fgrnd + 1;
- Attrib:= (Bgrnd shl 4) + Fgrnd;
- Qfill (Row,Col,Rows,Cols,Attrib,#178);
- end
- end;
-
- QfillC (10, 1,CRTCols, 6,34,Red shl 4,' ');
- QfillC (11, 1,CRTCols, 4,30,Brown shl 4,' ');
- Tattr:= Red shl 4 + Yellow;
- QwriteCV(12, 1,CRTCols,Tattr,Strng);
- QwriteC (13, 1,CRTCols,Tattr,' Version 2.1 ');
-
- { --- Save Screen for Page Demo --- }
- if MaxPage>0 then
- begin
- QstoreToMem ( 1, 1,25,CRTCols,SavedBlock);
- QwritePage (1);
- QstoreToScr ( 1, 1,25,CRTCols,SavedBlock);
- QwritePage (0);
- end;
- { --- End of Save Screen --- }
- Delay (Wait*4);
- Tattr:= Blue shl 4 + white;
- QwriteC ( 6, 1,CRTCols,Tattr,' Qwrite will write with new attributes ');
- QwriteC ( 7, 1,CRTCols,Tattr,' that you specify direct to the screen.');
- Delay (Wait*6);
- QwriteC (18, 1,CRTCols, -1,' Qwrite will also use existing attributes ');
- QwriteC (19, 1,CRTCols, -1,' when you do not even know or care. ');
- { highlight the word 'existing' }
- QattrC (18, 6,CRTCols+5,1,10,LightRed shl 4 + white);
- Delay (wait*10);
- QwriteC (21, 1,CRTCols,Tattr,' Say Goodbye to this screen. ');
-
- Delay (wait*3);
- { --- Disintigrate Screen --- }
- for i:=1 to 5000 do
- begin
- row:=random(25)+1;
- col:=random(CRTCols)+1;
- qfill (row,col, 1, 1,Black,' ');
- end;
-
- { --- Qwrite with Str on Reals Demo --- }
- Qfill ( 1, 1,25,CRTCols,Yellow,' '); { Clear Screen }
- QwriteC ( 2, 1,CRTCols, -1,'QwriteV with Turbo''s Str will write');
- QwriteC ( 3, 1,CRTCols, -1,'reals and integers faster:');
- Delay (wait*7);
- Rnum:=1.23E+05;
- for col:=0 to CRTCols div 20 -1 do
- for row:=5 to 24 do
- begin
- Rnum:=Rnum+1;
- Str(Rnum:12,NumStr);
- QwriteV (row,col*20+4, -1,NumStr);
- end;
- Delay (wait*12);
-
- { --- Centering Demo --- }
- Qfill ( 1, 1,25,CRTCols,LightGray shl 4,' '); { Clear Screen }
- QwriteC ( 2, 1,CRTCols, -1,'QwriteC and QwriteCV will automatically');
- QwriteC ( 3, 1,CRTCols, -1,'center your data ...');
- QwriteC ( 4, 1,CRTCols, -1,'(Odd breaks are shifted to the left.)');
- Delay (wait*6);
-
- { - Set up columns for varying column modes - }
- ColL[2]:=1; ColR[2]:=CRTCols;
- if CRTCols<80 then
- begin
- ColL[1]:=ColL[2]; ColL[3]:=CRTCols div 2;
- ColR[1]:=ColR[2]; ColR[3]:=CRTCols div 2;
- end
- else
- begin
- ColL[1]:=3; ColR[1]:=26; ColL[3]:=CRTCols-14; ColR[3]:=CRTCols-14;
- end;
-
- QwriteC ( 7,ColL[1],ColR[1], -1,'between margins ...');
- Qbox ( 8,(ColL[1]+ColR[1]) shr 1 -12,15,26,white,LightGray,Border);
- Delay (wait*3);
- for row:=11 to 19 do
- QwriteCV (row,ColL[1],ColR[1], -1, Data[row-10]);
- Delay (wait*5);
-
- QwriteC ( 7,ColL[2],ColR[2], -1,'between two columns ...');
- QfillC ( 9,ColL[2],ColR[2],13,24,Yellow,' '); { Clear window }
- for row:= 9 to 21 do
- QwriteC (row,ColL[2],ColR[2], -1,'><'); { Show two columns }
- Delay (wait*3);
- for row:=11 to 19 do
- QwriteCV (row,ColL[2],ColR[2],LightRed, Data[row-10]);
- Delay (wait*5);
-
- QwriteC ( 7,ColL[3],ColR[3], -1,'or on a center line ...');
- QfillC ( 8,ColL[3],ColR[3],15,27,LightGray shl 4,' '); { Clear window }
- for row:=09 to 21 do { Show center line }
- QwriteC (row,ColL[3],ColR[3],LightGray shl 4 + white,'|');
- Delay (wait*3);
- for row:=11 to 19 do
- QwriteCV (row,ColL[3],ColR[3], -1, Data[row-10]);
- Delay (wait*10);
-
- { --- Qfill Demo --- }
- Qfill ( 1, 1,25,CRTCols,white,' '); { Clear Screen }
- QwriteC ( 2, 1,CRTCols, -1,'Qfill as well as Qattr can fill');
- QwriteC ( 3, 1,CRTCols, -1,'your screen in several ways.');
- Delay (wait*7);
-
- QwriteC ( 7, 1,CRTCols, -1,'by rows ...');
- Delay (wait*3);
- for row:= 9 to 24 do
- Qfill (row, 2, 1,CRTCols-2,9+row,Chr(row+56));
- Delay (wait*5);
-
- Qfill ( 7, 1,19,CRTCols,white,' '); { Clear Lines }
- QwriteC ( 7, 1,CRTCols, -1,'by columns ...');
- Delay (wait*3);
- for col:=2 to CRTCols-2 do
- Qfill ( 9,col,16,1,16+col,chr(col+63));
- Delay (wait*5);
-
- Qfill ( 7, 1,19,CRTCols,white,' '); { Clear Lines }
- QwriteC ( 7, 1,CRTCols, -1,'or by row-by-column blocks ...');
- Delay (wait*3);
- Qfill ( 9,2,16,CRTCols-2,Blue shl 4 + Yellow,'!');
- Delay (wait*5);
-
- { --- Qbox demo --- }
- Qfill ( 1, 1,25,CRTCols,LightGray shl 4,' '); { Clear Screen }
- QwriteC ( 2, 1,CRTCols, -1,'Qbox is an application procedure made');
- QwriteC ( 3, 1,CRTCols, -1,'from QwriteV and Qfill. Together they');
- QwriteC ( 4, 1,CRTCols, -1,'can make windows with borders easy.');
- Delay (wait*9);
- QwriteC (14, 1,CRTCols, -1,'How about 100 of them? ... ');
- Delay (wait*4);
- ColMax:=CRTCols-21;
- for i:=1 to 100 do
- begin
- row:=random (10)+6;
- col:=random (ColMax)+2;
- BrdrAttr:=random (128);
- WndwAttr:=random (128);
- Qbox (row,col,10,20,BrdrAttr,WndwAttr,Border);
- end;
- Delay (wait*10);
-
- { --- Block Transfer and PopUp Demo --- }
- Qfill ( 1, 1,25,CRTCols,Yellow,'?'); { Clear Screen }
- QfillC (10, 1,CRTCols, 6,40,Brown shl 4,' '); { Clear Block }
- QwriteC (11, 1,CRTCols, -1,'Qstore will save and restore');
- QwriteC (12, 1,CRTCols, -1,'Row-by-Column blocks on your display.');
- QwriteC (13, 1,CRTCols, -1,'It is so fast, I have to slow it down');
- QwriteC (14, 1,CRTCols, -1,'so you can see it.');
- Delay (wait*11);
- BlkRow:=8;
- BlkCol:=CRTCols div 2 - 9;
- QstoreToMem(BlkRow,BlkCol,10,20,SavedBlock);
- { --- Make a Pop Up Menu --- }
- Qbox (BlkRow,BlkCol,10,20,Blue shl 4 + Yellow,Blue shl 4 + Brown,Border);
- QwriteC (BlkRow+4,BlkCol,BlkCol+20, -1,'Pop Up');
- QwriteC (BlkRow+5,BlkCol,BlkCol+20, -1,'Menu');
- { --- End of Pop Up Menu --- }
- QstoreToMem(BlkRow,BlkCol,10,20,PopUpBlock);
- Delay (wait*4);
- ColMax:=CRTCols-20;
- for i:=1 to 30 do
- begin
- Delay (Wait div 2);
- QstoreToScr(BlkRow,BlkCol,10,20,SavedBlock);
- BlkRow:=random(15)+1;
- BlkCol:=random(ColMax)+1;
- QstoreToMem(BlkRow,BlkCol,10,20,SavedBlock);
- QstoreToScr(BlkRow,BlkCol,10,20,PopUpBlock);
- end;
-
- { --- Page Demo --- }
- if MaxPage>0 then
- begin
- QviewPage (1);
- QwritePage (1);
- Tattr:= Blue shl 4 + Yellow;
- QwriteC (20, 1,CRTCols,Tattr,' Remember this page? ');
- QwriteC (21, 1,CRTCols,Tattr,' It wasn''t destroyed, but saved using ');
- QwriteC (22, 1,CRTCols,Tattr,' Qstores and placed on a new page. ');
- Delay (wait*14);
- QwritePage (0);
- QviewPage (0);
- end;
-
- { --- Attribute Demo --- }
- Qfill ( 1, 1,25,CRTCols,green shl 4 + green,' '); { Clear Screen }
- Tattr:= green shl 4 + white;
- QwriteC ( 2, 1,CRTCols,Tattr,'Q Screen Utilities is hiding strings on');
- QwriteC ( 3, 1,CRTCols,Tattr,'your screen ...');
- Cols:=CRTCols div 20;
- if Vmode=7 then Tattr:=0 else Tattr:= green shl 4 + green;
- for col:=0 to Cols-1 do
- for row:=5 to 20 do
- QwriteV (row,20*col+1,Tattr,Strng);
- Delay (wait*8);
-
- Qfill ( 2, 1, 2,CRTCols,-1,' '); { Clear Lines }
- Tattr:= green shl 4 + white;
- QwriteC ( 2, 1,CRTCols,Tattr,'Qattr can show them -');
- QwriteC ( 3, 1,CRTCols,Tattr,'by merely changing the attribute!');
- Delay (wait*6);
-
- { --- Try using Turbo's color procedures this time --- }
- TextColor (Black); TextBackground (Green);
- Qattr ( 5, 1,16,CRTCols,Tattr); { Reveal Data }
- Delay (wait*5);
-
- Qfill ( 2, 1, 2,CRTCols,-1,' '); { Clear Lines }
- TextColor (Yellow); TextBackground (Green);
- QwriteC ( 2, 1,CRTCols,Tattr,'Or even just emphasize what''s seen ...');
- for i:=1 to 500 do
- begin
- Row:= random(16) + 5;
- Col:= random(Cols)*20+1;
- Qattr (Row,Col, 1,20,46);
- Delay (3);
- Qattr (Row,Col, 1,20,32);
- end;
- for i:=1 to Cols do { Emphasize Data }
- Qattr ( 5*i,(i-1)*20+1, 1,20,LightGreen shl 4 + Yellow);
- QwriteC (24, 1,CRTCols,Tattr,' (c) 1986 James H. LeMay ');
- GotoRC (21, 1);
- CursorChange (OldCursor, OldCursor);
- end.
-